package com.ct.application.commons.validator.valid;

import com.ct.utils.valid.ValidatorUtil;
import org.apache.commons.lang3.StringUtils;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

public class IsMobileValidator implements ConstraintValidator<IsMobile,String> {

    //必填

    @Override
    public void initialize(IsMobile constraintAnnotation) {
    }

    @Override
    public boolean isValid(String s, ConstraintValidatorContext constraintValidatorContext) {
        if(StringUtils.isNotEmpty(s)) {
            return ValidatorUtil.isMobile(s);
        }
        return true;
    }
}
